package net.wangds.yunz.auth.ctrl;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * .
 * <p></p>
 *
 * @author 王东石 2020/6/14 16:26.
 */
@RestController
@RequestMapping("/balance")
public class BalanceCtrl {

    //@Autowired
    //private BalanceService mmServBlnc;

    //@Autowired
    //private M10AuthService mmServAuth;
    /*
    @ApiOperation("获得当前用户的账户余额信息.")
    @RequestMapping(value="/latest", method = RequestMethod.GET)
    public BaseResp<BalanceEntity> latest(){
        BaseResp<BalanceEntity> res = BaseResp.createDefault();
        String uid = SpringAuthUtils.getCurrentUid();
        Optional<BalanceEntity> op = mmServBlnc.latest(uid);

        op.ifPresent(res::success);
        if(!op.isPresent()){
            mmServAuth.findByLoginname(uid).ifPresent(usr-> res.success(BalanceEntity.createDefault(usr)));
        }

        return res;
    }

    @ApiOperation("充值.")
    @RequestMapping(value="/charge", method = RequestMethod.PUT)
    public BaseResp<BalanceEntity> charge(
            @RequestBody DepositForm form
            ){
        BaseResp<BalanceEntity> res = BaseResp.createDefault();
        String uid = SpringAuthUtils.getCurrentUid();
        Optional<BalanceEntity> op =  mmServBlnc.charge(uid, form.getCost());

        op.ifPresent(res::success);

        if(!op.isPresent()){
            mmServAuth.findByLoginname(uid).ifPresent(usr-> res.success(BalanceEntity.createDefault(usr)));
        }

        return res;
    }

    @ApiOperation("获得当前用户的账户余额信息.")
    @RequestMapping(value="/wallet", method = RequestMethod.GET)
    public BaseMultipleResp<BalanceEntity> wallet(){
        BaseMultipleResp<BalanceEntity> res = BaseMultipleResp.list(Collections.emptyList());

        String uid = SpringAuthUtils.getCurrentUid();
        List<BalanceEntity> list = mmServBlnc.listWallet(uid);
        res.success(list);

        return res;
    }


    @ApiOperation("判断当前账户是否冻结过指定拍品的参拍押金.")
    @RequestMapping(value="/isNeedFreezeAuction/{id}", method = RequestMethod.GET)
    public BaseResp<Boolean> isFreeze4Auction(
         @PathVariable("id") String archId
    ){
        BaseResp<Boolean> res = BaseResp.createDefault();

        res.success(mmServBlnc.isNeedFreeze4Auction(SpringAuthUtils.getCurrentUid(), archId));

        return res;
    }



     */


}
